import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../../r.dart';
import '../controllers/dd_my_follow_controller.dart';
import '../views/dd_my_block_cell.dart';

class DDMyFollowPage extends StatefulWidget {
  const DDMyFollowPage({Key? key}) : super(key: key);

  @override
  State<DDMyFollowPage> createState() => _DDMyFollowPageState();
}

class _DDMyFollowPageState extends State<DDMyFollowPage> {
  DDMyFollowController _controller = DDMyFollowController();

  @override
  Widget build(BuildContext context) {
    return GetBuilder<DDMyFollowController>(
        init: _controller,
        initState: (state) {},
        dispose: (state) {},
        builder: (controller) {
          return Scaffold(
            appBar: AppBar(
              backgroundColor: Color(0xFFE7F6FC),
              title: Text(
                'Follow List',
                style: TextStyle(fontSize: 18),
              ),
              leading: IconButton(
                icon: Image.asset(R.assetsImagesHomeSecond1),
                onPressed: () {
                  Get.back();
                },
              ),
            ),
            backgroundColor: Color(0xFFE7F6FC),
            body: Obx(
              () => _controller.datas.length == 0
                  ? SafeArea(
                      top: false,
                      child: Column(
                        children: [
                          SizedBox(
                            height: 148,
                          ),
                          Center(
                            child: Image.asset(R.assetsImagesPerson15),
                          )
                        ],
                      ))
                  : Stack(
                      children: [
                        Positioned.fill(
                          child: Image.asset(
                            R.assetsImagesPerson20,
                            fit: BoxFit.fill,
                          ),
                        ),
                        Positioned.fill(
                          child: SafeArea(
                            top: false,
                            child: Obx(
                              () => SingleChildScrollView(
                                child: Padding(
                                  padding: const EdgeInsets.all(16.0),
                                  child: _controller.datas.length == 0
                                      ? Column(
                                          children: [
                                            SizedBox(
                                              height: 148,
                                            ),
                                            Center(
                                              child: Image.asset(
                                                  R.assetsImagesPerson15),
                                            )
                                          ],
                                        )
                                      : ListView.builder(
                                          shrinkWrap: true,
                                          physics:
                                              NeverScrollableScrollPhysics(),
                                          itemBuilder: (context, index) {
                                            return DDMyFollowCell(
                                              model: controller.datas[index],
                                              onClick: () {
                                                _controller.updateMyFollow(
                                                    controller.datas[index]);
                                              },
                                              title: "Unfollow",
                                            );
                                          },
                                          itemCount: controller.datas.length),
                                ),
                              ),
                            ),
                          ),
                        ),
                      ],
                    ),
            ),
          );
        });
  }
}
